package leetcode.editor.cn;

public class _287_FindTheDuplicateNumber {
    public static void main(String[] args) {
        Solution solution = new _287_FindTheDuplicateNumber().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int findDuplicate(int[] nums) {
            int n = nums.length - 1;
            int[] count = new int[n];
            int res = 0;
            for (int num : nums) {
                count[num - 1]++;
                if (count[num - 1] == 2) {
                    res = num;
                    break;
                }
            }
            return res;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}